import axios from 'axios'
const http = axios.create()

http.defaults.timeout = 3000;
export function fetch(url, params) { 
    return new Promise((resolve, reject) => { // promise 用法
        axios.get(url, params).then(response => {
            resolve(response.data) // promise相关
        }).catch(error => {
            reject(error) // promise相关
        })
    })
}

export default { 
	// 暴露htto_mock方法，即后面页面中用到的方法
    http_mock(url, params) {
        return fetch(url, params)
    }
}